/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.perfectday.dashboard.gui.quests;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDialog;
import org.perfectday.oneplayer.battleloaders.model.Quest;

/**
 *
 * @author Miguel (alakat@gmail.com)
 */
public class SelectQuestDialog extends javax.swing.JDialog {

    private SelectQuestPanel panelQuest;
    private boolean questSelected;
    

    /**
     * Creates new form SelectQuestDialog
     */
    public SelectQuestDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        panelQuest = new SelectQuestPanel();
        this.panelBody.add(this.panelQuest);
        this.questSelected=false;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bodyPanel = new javax.swing.JPanel();
        cancelButton = new javax.swing.JButton();
        aceptButton = new javax.swing.JButton();
        panelBody = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setModal(true);
        setResizable(false);
        setSize(new java.awt.Dimension(400, 300));

        bodyPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        cancelButton.setText("Cancel");
        cancelButton.setToolTipText("");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        bodyPanel.add(cancelButton);

        aceptButton.setText("Aceptar");
        aceptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aceptButtonActionPerformed(evt);
            }
        });
        bodyPanel.add(aceptButton);

        getContentPane().add(bodyPanel, java.awt.BorderLayout.SOUTH);
        getContentPane().add(panelBody, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void aceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptButtonActionPerformed
        // TODO add your handling code here:
        this.questSelected=true;
        this.dispose();
    }//GEN-LAST:event_aceptButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        // TODO add your handling code here:
        this.questSelected=false;
        this.dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    public Quest getSelectedQuest() {
        return this.panelQuest.getSelectedQuest();
    }

    /**
     * Visible y pack especial en perfectday. Posiciona en el centro, agrupa
     * datos. coloca tama?os etc
     */
    public void PDshow() {

        this.setResizable(false);
        this.setLocationRelativeTo(null);

        this.setSize(new Dimension(600, 300));
        this.setVisible(true);
        this.pack();
        this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        final int width = this.getWidth();
        final int height = this.getHeight();
        final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screenSize.width / 2) - (width / 2);
        int y = (screenSize.height / 2) - (height / 2);
        this.setLocation(x, y);

    }

    public boolean isQuestSelected() {
        return questSelected;
    }

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton aceptButton;
    private javax.swing.JPanel bodyPanel;
    private javax.swing.JButton cancelButton;
    private javax.swing.JPanel panelBody;
    // End of variables declaration//GEN-END:variables
}
